package org.huangrui.spark.scala.sql

import org.apache.spark.sql.SparkSession

/**
 * @Author hr
 * @Create 2024-10-20 21:38 
 */
object SparkSQL08_Source_Hive {
  def main(args: Array[String]): Unit = {
    // TODO 在编码前，设定Hadoop的访问用户
    System.setProperty("HADOOP_USER_NAME", "huangrui")
    // TODO 启用Hive的支持
    val spark = SparkSession.builder.enableHiveSupport.appName("SparkSQL08_Source_Hive").master("local[2]").getOrCreate
    spark.sql("show tables").show()

    // spark.sql("create table user_info(name String,age bigint)");
    // spark.sql("insert into table user_info values('zhangsan',10)");
    spark.sql("select * from student").show()

    spark.stop()
  }
}
